#!/bin/bash

if [[ -z $GOPATH ]];then
    echo "GOPATH is empty"
    exit
fi

echo $GOPATH | grep ":"
if [[ $? == 0 ]];then
    GOPATH=${GOPATH//\\//}
    GOPATH=${GOPATH//:/}
    export GOPATH="/$GOPATH"
    echo $GOPATH
fi

useHttpProxy=1
if [[ $useHttpProxy == 1 ]];then
    echo "use http proxy"
    export http_proxy=socks5://127.0.0.1:1080
    export https_proxy=socks5://127.0.0.1:1080
else
    echo "use GOPROXY"
    export GO111MODULE=on
    export GOPROXY=https://goproxy.io
    cd $GOPATH/src > /dev/null
fi

go get $*
